import http from './../../../base/api/public'
import querystring from 'querystring'

let sysConfig = require('@/../config/sysConfig')
let apiUrl = sysConfig.sfsApiUrlPre;

//根据课程id查询课程计划列表
export const findTeachPlanList = courseId => {
  return http.requestQuickGet(apiUrl + '/course/teachPlan/list/' + courseId)
};

//查询课程计划
export const getTeachPlan = id => {
  return http.requestGet(apiUrl + '/course/teachPlan/get/' + id)
};

//添加课程计划
export const addTeachPlan = teachplah => {
  return http.requestPost(apiUrl + '/course/teachPlan/add', teachplah)
};

//修改课程计划
export const updateTeachPlan = teachplah => {
  return http.requestPut(apiUrl + '/course/teachPlan/update', teachplah)
};

//删除课程计划
export const deleteTeachPlan = id => {
  return http.requestDelete(apiUrl + '/course/teachPlan/delete/' + id)
};

//查询课程列表
export const findCourseList = (page, size, params) => {
//使用工具类将json对象转成key/value，params传入为空
  let queries = querystring.stringify(params);
  return http.requestQuickGet(apiUrl + "/course/coursebase/list/" + page + "/" + size + "?" + queries)
};

//查询课程分类
export const category_findlist = () => {
  return http.requestQuickGet(apiUrl + '/course/category/list')
};

//添加课程信息
export const addCourseBase = params => {
  return http.requestPost(apiUrl + '/course/coursebase/add', params)
};

//获取课程信息
export const getCoursebaseById = courseId => {
  return http.requestQuickGet(apiUrl + '/course/coursebase/get/' + courseId);
};

//更新课程信息
export const updateCoursebase = (id, params) => {
  return http.requestPut(apiUrl + '/course/coursebase/update/' + id, params);
};

//查询课程营销信息
export const getCourseMarketById = courseId => {
  return http.requestQuickGet(apiUrl + '/course/coursemarket/get/' + courseId);
};

//更新课程营销信息
export const updateCourseMarket = (courseId, params) => {
  return http.requestPut(apiUrl + '/course/coursemarket/update/' + courseId, params)
};

//保存课程图片地址到课程数据库
export const addCoursePic = (courseId, pic) => {
  return http.requestPost(apiUrl + '/course/coursepic/add?courseId=' + courseId + "&pic=" + pic)
};

//查询课程图片
export const findCoursePicList = courseId => {
  return http.requestQuickGet(apiUrl + '/course/coursepic/list/' + courseId)
};

//删除课程图片
export const deleteCoursePic = courseId => {
  return http.requestDelete(apiUrl + '/course/coursepic/delete?courseId=' + courseId)
};

//预览课程
export const preview = id => {
  return http.requestPost(apiUrl + '/course/preview/' + id);
};

//发布课程
export const publish = id => {
  return http.requestPost(apiUrl + '/course/publish/' + id);
};

//查询课程信息
export const findCourseView = courseId => {
  return http.requestQuickGet(apiUrl + '/course/courseview/' + courseId)
};

//保存媒资信息
export const savemedia = TeachPlanMedia => {
  return http.requestPost(apiUrl + '/course/savemedia', TeachPlanMedia);
};
